/**
 * @file		mount.h
 * @author		Fantei-Caujolle
 * @version   	$Rev: 79 $
 * @date       	25 Novembre 2011
 * $LastChangedDate: 2012-10-11 23:04:33 +0200 (jeu., 11 oct. 2012) $
 * @brief       Control general astronomic mount
 *
 * @details     this generic subclass control communication with astronomic mount system\n
 * this class inherit different class mount like ie. gto1200.cpp.
 *
 */
#ifndef TOOLS_H_
//#include "science/tools.h"
#endif
#include "logger/logmanager.h"
#ifndef ALGOSCI_H_
//#include "science/algosci.h"
#endif
#ifndef TYPE_H_
#include "type.h"
#endif

#include <QDate>
#include <QTime>
#include <QLineEdit>
#ifndef MOUNT_H
#define MOUNT_H

#include <QObject>

class mount:public QThread
{

public:
    mount();
    ~mount();
    // setters
    virtual int ReadConfigFile(QString path, QString key);
    virtual int SaveConfigFile(QString path, QString key);
    virtual	int SetLocalLongitude(CoordonneeGeo Localisation);
    virtual	int SetLocalLatitude(CoordonneeGeo Latitude);
    virtual	int SetGuideRate(double);
    virtual	int SetSlewRate(double);
    virtual int SetTracking(int mode);
    virtual void SetHorizonCheck(bool Horizon);
    virtual int SetBacklashDEC(CoordonneeEqu Coord);
    virtual int SetBacklashRA(CoordonneeEqu Coord);
    virtual int OpenPort();
    virtual int MoveNorth(int);
    virtual int Stop(QString);
    virtual int MoveSouth(int Time_ms);
    virtual int MoveEst(int Time_ms);
    virtual int MoveWest(int Time_ms);
    virtual int Goto(CoordonneeEqu coord);
    virtual int SetRA(CoordonneeEqu Coord);
    virtual int SetDEC(CoordonneeEqu Coord);


    // getters
    virtual int GetLocalTime(TimeStruct *LocalTime);
    virtual int GetRa(CoordonneeEqu *Coord);
    virtual int GetDec(CoordonneeEqu *Coord);
    virtual int GetVersion(QString *version);
    virtual int GetSidePier(QString *pier);
    virtual int GetAzimuth(StructDeg *CurrentAzimuth);
    virtual int GetAltitude(StructDeg *CurrentAltitude);
    //int GetHourAngle(TimeStruct SideralTime,CoordonneeEqu CurrentCoord,TimeStruct *HourAngle);
    //int GetSideralTime(CoordonneeGeo Coord,TimeStruct * time);
    bool getSimuMode();
    int getStatus();


    // mouvement
    virtual void SwapEW(void);
    virtual void SwapNS(void);
    virtual	void Park(void);
    virtual void UnPark(void);

    // convertion tools
    //int Convert2CoordGeo(QString Latitude, QString Longitude, QString Altitude, CoordonneeGeo *Coord);
    int Convert2CoordEqu(QString DEC, QString RA,CoordonneeEqu *coord);
    void Convert2String(CoordonneeGeo geo, QString * Longitude, QString * Latitude, QString * alt);
    void Convert2String(CoordonneeEqu equ, QString * DEC, QString * RA);
    CoordonneeEqu ConvertBacklashDEC(QString Declinaison);
    CoordonneeEqu ConvertBacklashRA(QString RA);

    // general
    void initGeneralParam(void);
    virtual void init();
    void MemTracking(int mode);

    // variables
    Monture			SettingsMount;		//!> Current settings of mount
    //algosci			*pScience;			//!> Science routines
    CoordonneeEqu	LastGoto;			//!> Last Goto coordonnee
    int				ErrorCode;			//!> Error code for this class
    bool			bSimu;				//!> Simulation indicator
    QMutex			*mutex;				//!> Mutex for thread use

protected:
    logmanager		*pLog;				//!> Logmanage pointer
};

#endif // MOUNT_H
